﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Text;
using FacebookWrapper;

namespace B13_Ex01_David_300512340_Alexey_321203689
{
    public class MainLogic
    {
        private const string k_ApplicationId = "167087790106782";
        private UserWrapper m_LoggedInUser;
        private LoginResult m_Result;

        public bool IsLogedIn { get; set; }

        public void Login()
        {
            m_Result = FacebookService.Login(k_ApplicationId, "user_status", "user_photos", "user_events", "friends_photos", "read_friendlists", "offline_access", "read_stream");
            if (string.IsNullOrEmpty(m_Result.ErrorMessage) && !string.IsNullOrEmpty(m_Result.AccessToken))
            {
                m_LoggedInUser = new UserWrapper();
                m_LoggedInUser.UserInformation = m_Result.LoggedInUser;
                FacebookService.s_CollectionLimit = 0; // Get all the collection information.
                IsLogedIn = true;
            }
            else
            {
                IsLogedIn = false;
                MessageBox.Show(m_Result.ErrorMessage);
            }
        }

        internal UserWrapper LoggedInUser
        {
            get { return m_LoggedInUser; }
        }
    }
}
